package com.paradogs.login.controller;

import com.paradogs.common.utils.JwtUtils;
import com.paradogs.common.utils.R;
import com.paradogs.login.config.ParadogsConfig;
import com.paradogs.login.pojo.dto.ServerListDTO;
import com.paradogs.login.pojo.vo.ServerListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: yumi
 * @date: 2024/10/9  20:20
 * @Description: TODO
 */
@CrossOrigin
@RestController
@RequestMapping("/server")
public class ServerController {

    @Autowired
    private ParadogsConfig config;

    /** 获取游戏服务器列表 */
    @PostMapping("/list")
    public R<List<ServerListVO>> list(@RequestBody ServerListDTO dto) {
        if (!JwtUtils.verifyToken(dto.getToken())) {
            return R.fail("token fail");
        }
        return R.success(config.getServers());
    }

}
